package com.zl.web.action;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.zl.domain.Dict;
import com.zl.service.DictService;
import com.zl.utils.FastJsonUtil;

public class DictAction extends ActionSupport implements ModelDriven<Dict>{


	private static final long serialVersionUID = 1L;

	private Dict dict = new Dict();
	
	private DictService dictservice;
	public void setDictservice(DictService dictservice) {
		this.dictservice = dictservice;
	}


	@Override
	public Dict getModel() {
		// TODO Auto-generated method stub
		return dict;
	}
	
	public String findByCode(){
		
	    List<Dict>list=dictservice.findByCode(dict.getDict_type_code());
		
	    String jsonString = FastJsonUtil.toJSONString(list);
//	    System.out.println(jsonString);
	    //把json写到浏览器
	    HttpServletResponse response = ServletActionContext.getResponse();
	    FastJsonUtil.write_json(response, jsonString);
	    
		return NONE;
	}

}
